AI-enhanced Structured Task System

2025

Overview

Video Demo:

demo

Description:

This project is a single-page web application for task management.
It is inspired by what I learned about SQL and web applications. Starting from database design, I designed a relational schema for tasks, and then extended it by integrating an external AI API and building a simple but intuitive frontend for manual task management and visualization. The core innovation of this project is that The LLM transforming natural language input into database-ready outputs, including fields such as priority, category, and subtasks.
Unlike traditional to-do list apps, this project treats tasks as structured data stored in a database. The combination of a data schema and an AI-powered workflow enhances task management capabilities while keeping the user experience easy to use.

Features

Problem

Solution

demo

Tech Stack

Project Structure

project/
├── app.py # Flask backend and API routes
├── ai_helper.py # AI-featured tools
├── helpers.py # Database tools and others
├── tododata.db # SQLite database
├── templates/
│ └── home.html # Single page
├── static/
│ ├── app.js # all Frontend logic
│ └── styles.css
└── requirements.txt

Database Design

The application uses a relational database (SQLite) to persist tasks and subtasks.
The schema is designed to support structured task data, inline editing, and future feature expansion.

demo

Schema

tasks table

ColumnTypeDescription
idINTEGERPrimary key
session_idTEXTAnonymous session identifier
titleTEXTTask title
completedINTEGERCompletion status (0 or 1)
priorityINTEGERTask priority (1–3)
categoryTEXTTask category
created_atTIMESTAMPCreation time

subtasks table

ColumnTypeDescription
idINTEGERPrimary key
task_idINTEGERReferences tasks(id)
titleTEXTSubtask title
completedINTEGERCompletion status (0 or 1)

Backend Architecture & API Design

The backend is designed as a lightweight REST-style API to support a single-page application (SPA).
All task operations are exposed through JSON-based endpoints,allowing flexible front-end interaction and future extensibility.
This API design allows the front-end to update individual fields (title, priority,category)without reloading the page, which was essential for achieving a smooth inline-editing experience.

Design Principles

API Endpoints

MethodEndpointDescription
GET/return home.html
GET/api/tasksGet all tasks with subtasks
POST/api/tasksCreate a new task
PATCH/api/tasks/Update a task field
DELETE/api/tasks/Delete a task and its subtasks
POST/api/tasks/<task_id>/subtasksAdd a subtask
PATCH/api/subtasks/Update a subtask field
DELETE/api/subtasks/Delete a subtask
POST/api/ai-parseParse natural language via AI

Design Decisions

demo

Prompt Engineering / Evaluation

Brief summary:
The goal of prompt engineering in this project was not simply to generate helpful text, but to reliably transform unstructured natural language into structured, database-ready task objects that conform to a predefined relational schema.

Baseline

The prompt needed to ensure:

Final prompt

''' You are a Task Parsing Assistant. Current date: {today.strftime(‘%Y-%m-%d’)}

Analyze the user’s task description and return a strict JSON in the following format:

{{ “title”: “Task title (concise and clear)”, “category”: “Study/Work/Life/Other”, “priority”: 1 or 2 or 3, “subtasks”: [“Subtask 1”, “Subtask 2”] (optional, for complex tasks) }}

Priority Rules:

Contains “urgent”, “important”, “asap”, or close to today → 1 (High)

Contains “not urgent”, “when free”, “later”, or far from today → 3 (Low)

Others → 2 (Medium)

Category Recognition:

Study-related (homework, exams, courses) → Study

Work-related (meetings, projects, tasks) → Work

Daily life (shopping, exercise, chores) → Life

Other → Other

Task Decomposition:

title + subtasks must cover all information from the user input. You may add decomposed subtasks but must not remove any information.

For large/complex tasks (e.g., “Complete CS Final Project”), automatically split into 2–6 subtasks in the subtasks array. Each subtask should take approximately 30 minutes–2 hours.

For simple tasks (e.g., “Buy milk”), return an empty array [] for subtasks.

If the task has nested or hierarchical elements, extract the main content as title and include other related items in subtasks.

If the task contains special terms or unclear intent, return the original input as title.

Language:

Use the language of the user input. If multiple languages are present, default to English.

Format:

Return pure JSON only, without any additional text.

Do not include Markdown code blocks or formatting. '''

Evaluation

To evaluate output quality, I designed both qualitative and quantitative evaluation.
Each output was scored independently.

Human Evaluation File: eval/ratings.csv

Metrics rated manually:

Quantitative Metrics
File: eval/metrics.csv

Metrics rated Automatically:

Future Improvements

Current approach: The app uses session-based anonymous users instead of login to keep it simple while still supporting persistent data. The schema is designed so it can be extended later.
Possible extensions:

How to Run

local run

  1. Install dependencies
cd /Users/yeahke/Desktop/CS50/CS50x/final
python3 -m venv venv   
source venv/bin/activate 
pip install -r requirements.txt
  1. Set environment variables copy .env.example -> .env and set OPENAI_API_KEY
cp .env.example .env

edit your .envfile with your API Key

AI_PROVIDER=openai
OPENAI_API_KEY=sk-your-actual-key-here
SECRET_KEY=any-random-string
  1. Run the application
python3 -m flask run  

or

python3 app.py
  1. Open browser

Access: http://localhost:5000

Common Questions

1. Don’t have an API Key?

2. Where is the database?

3. How to clear data?

rm todolist.db # Will be automatically recreated after deletion